<?php

/**
 * Description of ProductImages
 *
 * @author NguyenVanTien
 */
class ProductImagesController extends Zend_Controller_Action {

    /**
     * product model product image
     * @var Application_Model_ProductImage
     */
    private $_modelProductImage = null;
    private $_modelProduct = null;

    public function init() {
        parent::init();
        $this->_modelProductImage = new Application_Model_ProductImages();
        $this->_modelProduct = new Application_Model_Products();
    }

    public function showImagesProductDetailAction() {
        $productId = $this->_request->getParam('product-id');

        //get product
        $product = $this->_modelProduct->find($productId)->current();
        if (!is_null($product)) {
            //get product image
            $productImages = $this->_modelProductImage->getListImageProduct($productId);
            //echo '<pre>'; print_r($productImages->toArray()); die;
            //set view
            $this->view->productImages = $productImages;
        }else{
            $this->_redirect('/error/error/error_handler/EXCEPTION_OTHER');
        }
    }

}